package com.xyzq.model.ya.data;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "account_reward")
public class AccountMonthReward extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5611545578409027876L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "FK_ACCOUNT_ACCOUNT", nullable = false)
	private Account account;
	@Column(name = "reward_type")
	private String rewardType;
	@Column(scale = 2)
	private Double reward;
	private String month;
	private String remark;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;

	public void setAccountId(Integer accountId) {
		if(account==null){
			account=new Account();
		}
		this.account.setAccount(accountId);
	}

	public Long getId() {
		return id;
	}

	public Account getAccount() {
		return account;
	}

	public String getRewardType() {
		return rewardType;
	}

	public Double getReward() {
		return reward;
	}

	public String getMonth() {
		return month;
	}

	public String getRemark() {
		return remark;
	}

	public Date getSubTime() {
		return subTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public void setRewardType(String rewardType) {
		this.rewardType = rewardType;
	}

	public void setReward(Double reward) {
		this.reward = reward;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE);
		builder.append("id", id);
		builder.append("account", account);
		builder.append("rewardType", rewardType);
		builder.append("reward", reward);
		builder.append("month", month);
		builder.append("remark", remark);
		builder.append("subTime", subTime);
		return builder.toString();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AccountMonthReward other = (AccountMonthReward) obj;
		if (account == null) {
			if (other.account != null)
				return false;
		} else if (!account.equals(other.account))
			return false;
		if (month == null) {
			if (other.month != null)
				return false;
		} else if (!month.equals(other.month))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (reward == null) {
			if (other.reward != null)
				return false;
		} else if (!reward.equals(other.reward))
			return false;
		if (rewardType == null) {
			if (other.rewardType != null)
				return false;
		} else if (!rewardType.equals(other.rewardType))
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		result = prime * result + ((month == null) ? 0 : month.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((reward == null) ? 0 : reward.hashCode());
		result = prime * result
				+ ((rewardType == null) ? 0 : rewardType.hashCode());
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		return result;
	}

}
